<? include("/inc/header.html") {} ?>
<style>
.row{
	margin-bottom: 10px;
}
</style>
<div class="col-lg-12" style="overflow: auto;height: 500px;">
	<div class="panel panel">
		<div class="panel-body pan">
			<div class="form-body pal">
				<!-- <div class="row">
					<label for="inputUsername" class="col-md-3 control-label">手机号<span
						class='require'>*</span> </label>
					<div class="col-md-9">
						<div class="input-icon">
							<input id="telephone" type="text" class="form-control" />
						</div>
					</div>
				</div> -->
				<div class="row">
					<label for="inputUsername" class="col-md-3 control-label">用户头像
						<span class='require'>*</span> </label>
					<div class="col-md-9">
						<div class="input-icon">
							<img src="" style="height: 100px;" id='avatarImg'>
						</div>
					</div>
				</div>
				<div class="row">
					<label for="inputUsername" class="col-md-3 control-label">用户上传图片
						<span class='require'>*</span> </label>
					<div class="col-md-9">
						<div class="input-icon">
							<img src="" style="height: 100px;" id='cover'>
						</div>
					</div>
				</div>
				<div class="row">
					<label for="inputUsername" class="col-md-3 control-label">联系方式
						<span class='require'>*</span> </label>
					<div class="col-md-9">
						<div class="input-icon">
							<input id="contact" type="text" class="form-control" readonly="readonly"/>
						</div>
					</div>
				</div>
				<div class="row">
					<label for="inputUsername" class="col-md-3 control-label">评分
						<span class='require'>*</span> </label>
					<div class="col-md-9">
						<div class="input-icon">
							<input id="score" type="text" class="form-control" readonly="readonly"/>
						</div>
					</div>
				</div>
				<div class="row">
					<label for="inputUsername" class="col-md-3 control-label">意见内容
						<span class='require'>*</span> </label>
					<div class="col-md-9">
						<div class="input-icon">
							<textarea style="width: 100%;" rows="5" id="content" readonly="readonly"></textarea>
						</div>
					</div>
				</div>
				<div class="row">
					<label for="inputUsername" class="col-md-3 control-label">反馈内容（1000字以内）
						<span class='require'>*</span> </label>
					<div class="col-md-9">
						<div class="input-icon">
							<textarea style="width: 100%;" rows="5" id="feedback"></textarea>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<input id="id" type="hidden" value="${id}">
</div>
<script>
	$(function() {
		init();
	});
function init(){
	if($("#id").val() != null 
		&& $("#id").val() != ''
		&& $("#id").val() != 'null'
		&& $("#id").val() != 'undefined'
		&&$("#id").val() != undefined){
		
		$.ajax({
			type : "post",
			url : "./commentFind.do",
			data : {
				"id" : $("#id").val()
			},
			dataType : "json",
			success : function(data) {
				//$("#telephone").val(data[0].telephone);
				$("#content").val(data[0].content);
				$("#feedback").val(data[0].feedback);
				$("#avatarImg").attr("src",data[0].avatarImg);
				$("#cover").attr("src",data[0].cover);
				$("#contact").val(data[0].contact);
				$("#score").val(data[0].score);
			},
			error : function(data) {
				alert("请求失败");
			}
		});
	}else{
		layer.msg("此意见已经不存在 ");
	}
}
function save(){
	var id='';
	if($("#id").val() != null 
		&& $("#id").val() != ''
		&& $("#id").val() != 'null'
		&& $("#id").val() != 'undefined'
		&&$("#id").val() != undefined){
		id=$("#id").val();
	}
	
	/* if(!(/^1[34578]\d{9}$/.test($("#telephone").val()))){ 
        layer.msg("手机号码有误，请重填");  
        return false; 
	}  */
	
	if($("#telephone").val()==''){
		layer.msg("请输手机号");
		return false;
	}
	if($("#content").val()==''){
		layer.msg("没有意见内容无须反馈 ");
		return false;
	}
	if($("#feedback").val()==''){
		layer.msg("请输入反馈意见 ");
		return false;
	}
	if($("#feedback").val().length>1000){
		layer.msg("反馈意见:1000字以内 ");
		return false;
	}
	
	if(id==''){
		layer.msg("此意见已经不存在 ");
		return false;
	}
	$.ajax({
		type : "post",
		url : "./commentAddUpdate.do",
		data : {
			"id" : id,
			//"telephone" : $("#telephone").val(),
			"content" : $("#content").val(),
			"feedback" : $("#feedback").val(),
		},
		dataType : "json",
		success : function(data) {
			if(data[0].result == 'success'){
				var index = parent.layer.getFrameIndex(window.name);
				window.parent.get();
				parent.layer.msg('提交成功');
				parent.layer.close(index);
			}else{
				parent.layer.msg(data[0].msg);
			}
		},
		error : function(data) {
			alert("请求失败");
		}
	});
}
	
</script>